package com.cbg.sys.controller;

import com.cbg.base.constant.Constant;
import com.cbg.base.utils.Result;
import com.cbg.base.utils.SpringContextHolder;
import com.cbg.sys.entity.HistoryRoute;
import com.cbg.sys.mapper.HistoryRouteMapper;
import com.cbg.sys.service.IHistoryRouteService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.cbg.base.core.SuperController;
import java.util.stream.Collectors;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author chenbing
 * @since 2018-12-13
 */
@RestController
@RequestMapping("/sys/hisroute")
@Api(value = "历史路线控制器",tags = "历史路线操作接口")
public class HistoryRouteController extends SuperController<IHistoryRouteService, HistoryRoute> {
    @ApiOperation(value="获取历史路线信息", notes="只取HIS_SIZE条")
    @GetMapping("/all")
    public Result<?> historyRoute(){
        return Result.ok(SpringContextHolder.getBean(HistoryRouteMapper.class).hisRoutes(userId()).stream()
                .limit(Constant.HIS_SIZE).collect(Collectors.toList()));
    }
}
